package jsu.blogger.service.impl;
import jsu.blogger.mapper.CollectMapper;
import jsu.blogger.service.inter.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CollectServiceImpl implements CollectService {


    @Autowired
    private CollectMapper collectMapper;

    /**
     * 判断用户是否收藏了某个博客帖子
     *
     * @param userId 用户ID
     * @param postId 帖子ID
     * @return true 如果用户已收藏，false 如果没有收藏
     */
    public boolean hasUserCollectedPost(Long userId, Long postId) {
        Integer count = collectMapper.checkIfUserHasCollectedPost(userId, postId);
        //System.out.println("用户:"+userId+"收藏了"+postId+"数量:"+count);
        return count != null && count > 0;
    }

    public Integer countUserCollectedPost(Long userId, Long postId) {
        //System.out.println("用户:"+userId+"收藏了"+postId+"数量:"+count);
        return collectMapper.checkIfUserHasCollectedPost(userId, postId);
    }


}
